﻿using System;
using System.Xml;
using System.Xml.Serialization;
using rlTodayMakeSkin.Project.Attributes;
using rlTodayMakeSkin.Project;
using System.Drawing;

namespace rlTodayMakeSkin.Project.XmlElement.XmlSubElements
{
    public class HourHand : XmlSubElement
    {
        private bool show = false;
        private Color colore = Color.Black;
        private string filename = "";

        public HourHand(rlTodayXmlElement parent)
            : base(parent)
        {

        }

        public HourHand(XmlAttributeCollection attr, rlTodayXmlElement parent) : base(parent)
        {
            if( attr["show"] != null) show = Boolean.Parse(attr["show"].Value);
            if( attr["color"] != null) colore = rlTodayXmlElement.GetColorFromRGB(attr["color"].Value);
            if( attr["source"] != null) filename = attr["source"].Value;
        }

        /// <summary>
        /// for the serialization
        /// </summary>
        public HourHand() { }

        /// <summary>
        /// true or false
        /// </summary>
        [PropertyDescription("true or false", PropertyTypes.BOOLEAN)]
        [XmlAttribute("show")]
        public bool Show
        {
            get { return show; }
            set { show = value; }
        }

        /// <summary>
        /// Gets, sets the color for this element
        /// </summary>
        [PropertyDescription("color for this element", PropertyTypes.COLOR)]
        [XmlIgnore()]
        public Color HourHandColor
        {
            get { return colore; }
            set { colore = value; }
        }

        /// <summary>
        /// Returns a string rapresentation of this color 
        /// in the format "RGB(R, G, B)"
        /// </summary>
        [PropertyDescription("a string rapresentation of this color", ReadOnlyProperty=true)]
        [XmlAttribute("color")]
        public string RGBColor
        {
            get { return rlTodayXmlElement.GetRGBFromColor(colore); }
        }

        /// <summary>
        /// Gets, sets filename of the image to be used as hand
        /// </summary>
        [PropertyDescription("filename of the image to be used as hand", PropertyTypes.FILE_IMAGE)]
        [XmlAttribute("source")]
        public string Source
        {
            get { return filename; }
            set { filename = value; }
        }

        public override bool isEmpty()
        {
            return filename == "";
        }
    }
}
